/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package games.freecell.core;

import commomgame.RulesOfMovement;
import commomgame.SubRegion;

/**
 *
 * @author ian
 */
public class RulesOfFoundations extends RulesOfMovement {

    @Override
    public boolean verifyMovement(int value, String nipe, SubRegion regionOrigin, SubRegion regionTarget) {
        
        if (this.isEmptyStack(regionTarget)) {
            if (this.isAs(regionOrigin)) {
                //regionTarget.addCardInSubRegion(regionOrigin.selectCard(value, nipe));
                //regionOrigin.removeCard(regionOrigin.selectCard(value, nipe));
                if (!regionOrigin.setOfCard.isEmpty()) {
                    regionOrigin.setOfCard.get(0).setIsShowed(true);
                }
                return true;
            }
        } else {
            if (regionTarget.showNipeTopOfSubRegion().equals(nipe)) {
                if (this.isAscendent(regionTarget, value)) {
                    //regionTarget.addCardInSubRegion(regionOrigin.selectCard(value, nipe));
                    //regionOrigin.removeCard(regionOrigin.selectCard(value, nipe));
                    if (!regionOrigin.setOfCard.isEmpty()) {
                        regionOrigin.setOfCard.get(0).setIsShowed(true);
                    }
                    return true;
                }
            } else {
                return false;
            }
        }
        return false;


    }
}
